const app = getApp();

Page({
  data: {
    userInfo: {},
    hasUserInfo: false,
  },
  login() {
    wx.getUserProfile({
      desc: '你管我干啥用？', 
      success: (res) => {
        app.globalData.userInfo = res.userInfo
        app.apis.getUserInfo(
            app.globalData.code,
            res.encryptedData,
            res.iv
        ).then(res=>{
          if (res.code === 0){
            app.globalData.login = true
            wx.redirectTo({
              url:"../tag/index"
            })
          }
        })
        this.setData({
          userInfo: res.userInfo,
          hasUserInfo: true
        })
      }
    })
  },
})